/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package expo43gamestartingclient;

import java.io.*;
import java.net.*;

/**
 *
 * @author TommySprat
 */
public class Expo43GameStartingClient {

    static Socket e43Socket = null;
    static PrintWriter out = null;
    static BufferedReader in = null;
    static String HOST = "localhost";

    public static void main(String[] args) throws IOException {
        try {
            e43Socket = new Socket(HOST, 4450);
            out = new PrintWriter(e43Socket.getOutputStream(), true);
            in = new BufferedReader(new InputStreamReader(e43Socket.getInputStream()));
        } catch (UnknownHostException e) {
            System.err.println("Don't know about host: " + HOST);
            System.exit(1);
        } catch (IOException e) {
            System.err.println("Couldn't get I/O for the connection to: " + HOST + "\n Check if the IP adress is correct and the Expo43Menu is running there");
            System.exit(1);
        }

        BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
        String fromServer;
        String toServer = null;

        while ((fromServer = in.readLine()) != null) {
            System.out.println("Server: " + fromServer);
            if (fromServer.equals("Bye.")) {
                break;
            }
            if (fromServer.equals("startgame")) {
                Process proc = Runtime.getRuntime().exec("C:\\Expo43Menu\\python.bat");
            }
        }
    }
}
